package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class panou1 extends MovieClip
	{
		var bGround : backGround = new backGround();
		var Grafic : graficEcuatie = new graficEcuatie();
		
		var axx : myText = new myText("input");
		var bx : myText = new myText("input");
		var c : myText = new myText("input");
		
		var axx1: myText = new myText("dynamic");
		var bx1 : myText = new myText("dynamic");
		
		var plus1 : myText = new myText("dynamic");
		var plus2 : myText = new myText("dynamic");
		var egal : myText = new myText("dynamic");
		var zero : myText = new myText("dynamic");
		
		var info : myText = new myText("dynamic");
		
		var unitate : myText = new myText("input");
		var infoU : myText = new myText("dynamic");
		
		var buton1 : myButton = new myButton();
		
		public function panou1()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,initializare);
		}
		
		private function initializare(e:Event):void
		{
			this.addChild(bGround);
			this.addChild(Grafic);
			
			pozitioneazaObiecte();
			
			buton1.addEventListener(MouseEvent.CLICK,b1Click);
		}
		
		private function b1Click(e:MouseEvent):void
		{
			traseazaGrafic();
		}
		
		private function traseazaGrafic():void
		{
			var a1,b1,c1 : int;
			var unit : Number;
			a1 = parseFloat(axx.text);
			b1 = parseFloat(bx.text);
			c1 = parseFloat(c.text);
			unit = parseFloat(unitate.text);

			if(unit < 0.1 || unit > 100)
			{
				unit = 10;
				unitate.text = ""+unit;
			}
			
			Grafic.Grafic.setUnitate = unit;
			
			Grafic.traseazaGrafic(a1,b1,c1);
		}
		
		private function pozitioneazaObiecte():void
		{
			bGround.y = 30;
			
			Grafic.x = 10;
			Grafic.y = 40;
			
			info.x = Grafic.width+30;
			info.y = 50;
			info.width=40;
			info.text = "Ecuatia";
			this.addChild(info);
			
			axx.x = Grafic.width+15;
			axx.y = info.y+info.height+10;
			axx.text = "0";
			this.addChild(axx);
			
			axx1.x = axx.x+axx.width+1;
			axx1.y = axx.y;
			axx1.text = "x^2";
			this.addChild(axx1);
			
			plus1.x = axx1.x+axx1.width+1;
			plus1.y = axx.y;
			plus1.text = "+";
			this.addChild(plus1);
			
			bx.x = plus1.x+8+1;
			bx.y = axx.y;
			bx.text = "0";
			this.addChild(bx);
			
			bx1.x = bx.x+bx.width+1;
			bx1.y = axx.y;
			bx1.text = "x";
			this.addChild(bx1);
			
			plus2.x = bx1.x+8+1;
			plus2.y = axx.y;
			plus2.text = "+";
			this.addChild(plus2);
			
			c.x = plus2.x+8+1;
			c.y = axx.y;
			c.text = "0";
			this.addChild(c);
			
			egal.x = c.x+c.width+1;
			egal.y = axx.y;
			egal.text = "=";
			this.addChild(egal);
			
			zero.x = egal.x+8+1;
			zero.y = axx.y;
			zero.text = "0";
			this.addChild(zero);
			
			buton1.x = Grafic.x+Grafic.width+20;
			buton1.y = axx.y+axx.height+20;
			buton1.nume = "   Traseaza";
			this.addChild(buton1);

			infoU.x = Grafic.x+Grafic.width+20;
			infoU.y = buton1.y+buton1.height+20;
			infoU.width = 45;
			infoU.text = "Unitate: ";
			this.addChild(infoU);
			
			unitate.x = infoU.x+infoU.width+1;
			unitate.y = infoU.y;
			unitate.width = 25;
			unitate.text = "10";
			this.addChild(unitate);
		}
	}
}